import React, { useEffect } from 'react'
import Taro from '@tarojs/taro'
import './app.scss'
import { View } from '@tarojs/components'

const App: React.FC = (props) => {
  useEffect(() => {
    Taro.getStorage({
      key: 'userInfo',
      success: (res) => {
        console.log(res)
        if (res.data.name === undefined) {
          Taro.reLaunch({
            url: '/pages/login/login',
          })
          return
        }
      },
      fail: () => {
        Taro.reLaunch({
          url: '/pages/login/login',
        })
      },
    })
      .catch(() => {})
      .finally(() => {})
  }, [])
  return <View>{props.children}</View>
}

export default App
